package run.demo;

import org.apache.activemq.util.FactoryFinder;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;

public class LoadClass {
    @Test
    public void verify() throws IOException {
        // org.apache.activemq.transport.stomp.StompTransportFactory
        String uri ="META-INF/services/org/apache/activemq/transport/stomp";
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader == null) {
            classLoader = LoadClass.class.getClassLoader();
        }
        InputStream in = classLoader.getResourceAsStream(uri);
        if (in == null) {
            in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
            if (in == null) {
                throw new IOException("Could not find factory class for resource: " + uri);
            }
        }

    }
}
